<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<#include "/admin/include/head.htm">
<script type="text/javascript">
	//删除文章栏目
	function deleteArticle_category(){
      	jQuery.ligerDialog.confirm('确定删除吗?', function (confirm) {
      		if (confirm){
				LG.ajax({
					url: "delete.jhtml",
					data: {"ids":$("#article_category_id").val()},
					success: function(result){
						LG.showSuccess("删除类别成功!");
						window.parent.leftFrame.removeNode($("#article_category_id").val());
						if(result.pId){
							window.location.href="${base}/admin/system/articleCategory/add.jhtml?id=" + result.pId;
						}else{
							window.location.href="${base}/admin/system/articleCategory/add.jhtml";
						}
						
					}
				});
			}
		});
	}
	
	//添加部门
	function add(){
		LG.submitForm($("#childForm"), function(data){
			window.parent.leftFrame.addNode(data, false);
			LG.showSuccess("添加文章类别成功!");
			$("#childForm").clearForm();
		});
	}
	
	//编辑部门
	function edit(){
		LG.submitForm($("#currentDept"), function(data){
			window.parent.leftFrame.updateNode(data);
			LG.showSuccess("修改文章类别成功!");
		});
	}
</script>
</head>
<body>
<div class="body-box">
<#if article_category?? && article_category.id??>
	<div class="currentDept">
		<div class="table_title">
			<img src="${base}/resource/images/communication.gif" />
			<span>修改文章类别 </span>
		</div>
		<form action="update.jhtml" method="post" id="currentDept">
			<input type="hidden" name="id" value="${(article_category.id)!''}" id="article_category_id"/>
			<table class="table">
				<tr>
					<th>类别名称:</th>
					<td><input type="text" class="formText {required: true, maxlength: 20}" value="${(article_category.name)!''}" maxlength="20"
						name="name"/>
					</td>
				</tr>
				<tr>
					<th>类别编码:</th>
					<td><input type="text" class="formText {required: true, remote: 'checkCode.jhtml?oldValue=${(article_category.code)!''}',maxlength:12, minlength:2, messages:{remote: '类别编号不能重复!'}}" 
							value="${(article_category.code)!''}" maxlength="20" name="code"/>
					</td>
				</tr>
				<tr>
					<th>链接地址:</th>
					<td><input type="text" class="formText {maxlength: 255}" value="${(article_category.url)!''}" name="url" style="width: 300px;"/></td>
				</tr>
				<tr>
					<th>链接模板:</th>
					<td>
						<input type="text" class="formText {maxlength: 255}" value="${(article_category.template)!''}" name="template" />
					</td>
				</tr>
				<tr>
					<th>排序:</th>
					<td><input type="text" class="formText {digits:true}" value="${(article_category.priority)!''}" name="priority" maxlength="3"/></td>
				</tr>
				<tr>
					<th>是否有子节点:</th>
					<td><@u.radio name="hasChild" list={"true":"允许", "false": "不允许"} 
					value="${(article_category.hasChild?string('true', 'false'))!'false'}"/></td>
				</tr>
			<tr>
				<th>类别描述:</th>
					<td>
						<textarea name="metaDescription" class="formTextarea formText{maxlength: 255}" maxlength="255" style="width:300px;height:56px">${(article_category.metaDescription)!''}</textarea>
					</td>
				</tr>
			<tr>
				<tr>
					<th></th>
					<td>
						<#if !update?? || update>
							<input type="button" class="button" value="保存" onclick="edit();"/>
						</#if>
						<#if !delete?? || delete>
							<input type="button" class="button" value="删除" onclick="deleteArticle_category();"/>
						</#if>
					</td>
				</tr>
			</table>
		</form>
	</div>
</#if>
<#if (!(article_category??)||(article_category??&&(article_category.hasChild)))&&(!add?? || add)>
<div class="childChild">
	<div class="table_title">
		<img src="${base}/resource/images/communication.gif" />
		<span>添加文章类别</span>
	</div>
	<form action="save.jhtml" method="post" id="childForm">
		<#if article_category?? && article_category.id??>
			<input type="hidden" name="parent.id" value="${(article_category.id)!''}"/>
		</#if>
		<table class="table">
			<tr>
				<th>类别名称:</th>
				<td><input type="text" class="formText {required: true}" name="name" maxlength="20"/></td>
			</tr>
			<tr>
				<th>类别编码:</th>
				<td><input type="text" class="formText {required: true, remote: 'checkCode.jhtml?oldValue=${(article_category.code)!''}',maxlength:12, minlength:2, messages:{remote: '类别编号不能重复!'}}" 
						value="${(article_category.code)!''}" maxlength="20" name="code"/>
				</td>
			</tr>
			<tr>
				<th>链接地址:</th>
				<td><input type="text" class="formText {maxlength: 255}" value="" name="url" style="width: 300px;"/></td>
			</tr>
			<tr>
				<th>链接模板:</th>
				<td>
					<input type="text" class="formText {maxlength: 255}" value="${(article_category.template)!''}" name="template" />
				</td>
			</tr>
			<tr>
				<th>排序:</th>
				<td><input type="text" class="formText {digits:true}" value="" name="priority" title="只允许输入零或正整数"/></td>
			</tr>
			<tr>
				<th>是否有子节点:</th>
				<td><@u.radio name="hasChild" list={"true":"允许", "false": "不允许"} 
					value="false"/></td>
			</tr>
			<tr>
				<th>类别描述:</th>
				<td>
					<textarea name="metaDescription" class="formTextarea" style="width:300px;height:56px" ></textarea>
				</td>
			</tr>
			<tr>
				<th></th>
				<td><input type="button" class="button" value="添加" onclick="add();"/></td>
			</tr>
		</table>
	</form>
</div>
</#if>
</div>
</body>
</html>